package com.meeting.project.business.record.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.meeting.framework.aspectj.lang.annotation.Log;
import com.meeting.framework.aspectj.lang.enums.BusinessType;
import com.meeting.project.business.record.domain.SignInRecord;
import com.meeting.project.business.record.service.ISignInRecordService;
import com.meeting.framework.web.controller.BaseController;
import com.meeting.framework.web.domain.AjaxResult;
import com.meeting.common.utils.poi.ExcelUtil;
import com.meeting.framework.web.page.TableDataInfo;

/**
 * 人员签到信息Controller
 * 
 * @author llmaoa
 * @date 2025-08-05
 */
@Controller
@RequestMapping("/business/record")
public class SignInRecordController extends BaseController
{
    private String prefix = "business/record";

    @Autowired
    private ISignInRecordService signInRecordService;

    @RequiresPermissions("business:record:view")
    @GetMapping()
    public String record()
    {
        return prefix + "/record";
    }

    /**
     * 查询人员签到信息列表
     */
    @RequiresPermissions("business:record:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SignInRecord signInRecord)
    {
        startPage();
        List<SignInRecord> list = signInRecordService.selectSignInRecordList(signInRecord);
        return getDataTable(list);
    }

    /**
     * 导出人员签到信息列表
     */
    @RequiresPermissions("business:record:export")
    @Log(title = "人员签到信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SignInRecord signInRecord)
    {
        List<SignInRecord> list = signInRecordService.selectSignInRecordList(signInRecord);
        ExcelUtil<SignInRecord> util = new ExcelUtil<SignInRecord>(SignInRecord.class);
        return util.exportExcel(list, "人员签到信息数据");
    }

    /**
     * 新增人员签到信息
     */
    @RequiresPermissions("business:record:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人员签到信息
     */
    @RequiresPermissions("business:record:add")
    @Log(title = "人员签到信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SignInRecord signInRecord)
    {
        return toAjax(signInRecordService.insertSignInRecord(signInRecord));
    }

    /**
     * 修改人员签到信息
     */
    @RequiresPermissions("business:record:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SignInRecord signInRecord = signInRecordService.selectSignInRecordById(id);
        mmap.put("signInRecord", signInRecord);
        return prefix + "/edit";
    }

    /**
     * 修改保存人员签到信息
     */
    @RequiresPermissions("business:record:edit")
    @Log(title = "人员签到信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SignInRecord signInRecord)
    {
        return toAjax(signInRecordService.updateSignInRecord(signInRecord));
    }

    /**
     * 删除人员签到信息
     */
    @RequiresPermissions("business:record:remove")
    @Log(title = "人员签到信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(signInRecordService.deleteSignInRecordByIds(ids));
    }
}
